package com.etime.shycourse.services.coupons.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.etime.shycourse.services.coupons.interfaces.ActivelogServices;
import com.etime.shycourse.dao.ActiveLogMapper;
import com.etime.shycourse.dto.ActivelogDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName : ActivelogServices  //类名
 * @Description : 活动参与记录  //描述
 * @Author : W //作者
 * @Date: 2022/3/30  17:28
 */
@Service
public class ActivelogServicesImpl implements ActivelogServices {
    @Autowired
    private ActiveLogMapper mapper;

    /**
     * 活动参与记录 分页
     * <p></p>
     * 可根据的查询的条件有：
     * 活动模糊搜索 coupontitle
     * 活动状态 couponlogtype
     * 领取时间 couponlogtime
     *
     * @param pageNum,     第几页       可不传
     * @param pageSize     一页多少数据  可不传
     * @param activelogDto
     * @return Page<ActivelogDto>
     */

    @Override
    public Page<ActivelogDto> selectActiveLogPage(ActivelogDto activelogDto, Long pageNum, Long pageSize) {
        Page<ActivelogDto> page;
        if (pageNum != null & pageSize != null) {
            page = new Page<>(pageNum, pageSize);
        } else {
            page = new Page<>();
        }
        // 进行拼接 模糊查询
        if (activelogDto.getActivetitle() != null) {
            activelogDto.setActivetitle("%" + activelogDto.getActivetitle().trim() + "%");
        }
        if (activelogDto.getActivefromusername() != null) {
            activelogDto.setActivefromusername("%" + activelogDto.getActivefromusername().trim() + "%");
        }
        if (activelogDto.getActivetousername() != null) {
            activelogDto.setActivetousername("%" + activelogDto.getActivetousername().trim() + "%");
        }
        return mapper.selectActivelogDtoPage(activelogDto, page);
    }
}

